﻿
Ext.define("app.main.home.Work",
{
    extend: 'Ext.panel.Panel',
    // title: '待办事项',
    tbar: [],
    cls: 'images-view',
    initComponent: function () {
        var me = this;
        me.items = [
            me.getDataView()
        ];

        me.tbar = ["<b>参与的问题</b>", "->", {
            text: '刷新',
            glyph: 0xf021, handler: function () { me.store.load(); }
        }];
        me.callParent(arguments);
    },
    getDataView: function () {
        var me = this;
        if (!this.dataView) {
            me.store = Ext.create("app.ux.PrmStore", { url: '/api/services/app/projectTask/GetMyWork' });

            this.dataView = new Ext.view.View({
                store: me.store,
                tpl: [
                    '<tpl for=".">',
                        '<div style="margin:5px">',
                            //'<a href="javascript:void(0)">({ProjectName}){title}</a>',
                            '(<span style="color:red">{projectName}</span>){title}<span style="color:red">({planFinshTime}){members}</span>',
                        '</div>',
                    '</tpl>'
                ],
                multiSelect: true,
                autoHeight: true,
                trackOver: true,
                overItemCls: 'x-item-over',
                itemSelector: 'div',
                emptyText: '暂无待办',
                prepareData: function (data) {
                    return data;
                },
                listeners: {
                    itemclick: 'onWorkOpen'
                }
            });
        }
        return this.dataView;
    },
    doTask: function () {
        var me = this;

        var task = {
            run: function () {
                me.store.load();
            },
            interval: 5 * 60 * 1000
        }
        Ext.util.TaskManager.start(task);
    },
    listeners: {
        afterrender: function (win) {
            win.doTask();
        }
    }
});